import { defineConfig } from 'vitepress'
import { componentPreview, containerPreview } from '@vitepress-demo-preview/plugin'

const buildTransformers = () => {
  const transformer = () => {
    return {
      props: [],
      needRuntime: true,
    }
  }

  const transformers = {}
  const directives = [
    'infinite-scroll',
    'loading',
    'popover',
    'click-outside',
    'repeat-click',
    'trap-focus',
    'mousewheel',
    'resize',
  ]
  directives.forEach((k) => {
    transformers[k] = transformer
  })

  return transformers
}
// https://vitepress.dev/reference/site-config
export default defineConfig({
  title: "WideEle Ui",
  siteTitle: 'WideEle Ui 更高效更实用的企业级全场景组件库',
  description: "基于Element Plus二次封装拓展，一款开箱即用、面向敏捷开发的web lib",
  // appearance: 'dark',

  themeConfig: {
    langMenuLabel: '多语言', // 多语言切换标签（如果启用了多语言功能）
    returnToTopLabel: '回到顶部', // 回到顶部按钮标签
    sidebarMenuLabel: '菜单', // 侧边栏菜单标签
    darkModeSwitchLabel: '主题', // 深色模式切换标签
    lightModeSwitchTitle: '切换到浅色模式', // 切换到浅色模式提示
    darkModeSwitchTitle: '切换到深色模式', // 切换到深色模式提示
    outlineTitle: '目录', // 大纲标题（如果启用了大纲功能）
    // 文档页脚配置
    docFooter: {
      prev: '上一页',
      next: '下一页',
    },
    logo: "/logo-shadow.svg",
    search: {
      provider: 'local'
    },
    // https://vitepress.dev/reference/default-theme-config
    nav: [
      { text: '指南', link: '/about' },
      { text: '组件', link: '/installation' },
      {
        text: "微前端框架Cli（筹备中）",
        link: ""
      },
    ],

    sidebar: [

      {

        text: '开发指南',
        items: [
          { text: '更新日志', link: '/README' },
          { text: '为什么需要WideEle Ui？', link: '/about' },
          { text: '快速上手', link: '/installation' }
        ]
      },
      {
        text: '基础组件',
        items: [
          { text: 'Button 按钮', link: '/components/exp-button' },
          { text: 'Layout 布局', link: '/components/exp-row' },
          { text: 'Tabel 表格', link: '/components/exp-table' },
          { text: '更多组件开发中...', link: '' },
        ]
      },
      {
        text: '全局方法',
        items: [
          { text: 'axios 数据请求', link: '/components/more' },
          { text: 'localStorage 浏览器缓存', link: '/components/more' },
          { text: 'dates 时间日期处理', link: '/components/more' },
          { text: 'theme 皮肤主题', link: '/components/more' },

        ]
      },
      {
        text: '即时通讯',
        items: [
          { text: 'webSocket', link: '/components/more' },
        ]
      }
    ],

    socialLinks: [
      { icon: 'github', link: 'https://github.com/vuejs/vitepress' },
      { icon: {
        svg: '<svg height="32" viewBox="0 0 32 32" width="32" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><circle cx="16" cy="16" fill="#c71d23" r="16"/><path d="m24.0987698 14.2225144h-9.0863697c-.4362899.000207-.7900048.3538292-.790326.7901191l-.0005173 1.9752185c-.0003277.4363707.353328.7902117.7896987.790326.0000712 0 .0001424 0 .0002135-.0002135l5.5317648-.0000461c.4363708-.0000102.7901221.3537352.7901257.790106 0 .0000022 0 .0000044-.0000066.0000066v.1975077.1975318c0 1.3091122-1.0612451 2.3703573-2.3703573 2.3703573h-7.5067195c-.4363081-.0000218-.790009-.353713-.7900429-.7900211l-.0002069-7.5059917c-.0001014-1.3091122 1.0611145-2.3703865 2.3702267-2.3704226.0000217 0 .0000435 0 .0000653.0000653h11.0602463c.4361793-.0004902.7898484-.35394.7906091-.79011894l.0012251-1.97521881c.0007606-.43637034-.3527683-.79033806-.7891389-.79060871-.0001634-.0000001-.0003268-.00000015-.0004901.00048976h-11.0617654c-3.27278051 0-5.92589329 2.65311278-5.92589329 5.9258933v11.0612755c0 .4363707.35374837.7901191.7901191.7901191h11.65447149c2.9454379 0 5.3331872-2.3877493 5.3331872-5.3331872v-4.5430682c0-.4363707-.3537484-.7901191-.7901191-.7901191z" fill="#fff"/></g></svg>'
      }, link: 'https://gitee.com/handsome_zs/WideEle-Ui' }
    ],
    footer: {
      message: '基于 MIT 许可发布.',
      copyright: '版权所有 © 2024-2025 钟顺/@handsome_zs'
    }
  },
  vue: {
    template: {
      ssr: true,
      compilerOptions: {
        directiveTransforms: buildTransformers(),
      },
    },
  },

  markdown: {
    lineNumbers: true,
    config(md) {
      md.use(componentPreview)
      md.use(containerPreview)
    }
  }
})